package com.funny.learning.english.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.funny.learning.english.R;
import com.funny.learning.english.model.CourseEntity.Level;

public class LearnedCourseAdapter extends BaseAdapter{
	private ArrayList<Level> courseEntities;
	private LayoutInflater inflater;

	public LearnedCourseAdapter(Context context, ArrayList<Level> courseEntities) {
		inflater = LayoutInflater.from(context);
		this.courseEntities = courseEntities;
	}
	@Override
	public int getCount() {
		return courseEntities.size();
	}

	@Override
	public Level getItem(int arg0) {
		return courseEntities.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		if(arg1 == null){
			arg1 = inflater.inflate(R.layout.learned_course_item, null);
		}
		ImageView ivAvatar = (ImageView)arg1.findViewById(R.id.ivAvatar);
		TextView tvNameCourse = (TextView)arg1.findViewById(R.id.tvNameCourse);
		TextView tvDes = (TextView)arg1.findViewById(R.id.tvDes);
		TextView tvLevel = (TextView)arg1.findViewById(R.id.tvLevel);
		Level level = courseEntities.get(arg0);
		if(level != null){
//			tvNameCourse.setText(level.getName());
//			tvDes.setText(level.getContent());
		}
		return arg1;
	}

}
